package com.systop.asset.controller;


import com.systop.asset.entity.DeptUser;
import com.systop.asset.entity.RestResponse;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.systop.asset.service.IDeptUserService;

import java.util.List;

/**
 * 部门人员组织架构Controller
 * 
 * @author lsp
 * @date 2025-06-26
 */
@RestController
@RequestMapping("/deptuser")
public class DeptUserController
{
    @Autowired
    private IDeptUserService deptUserService;

    /**
     * 查询部门人员组织架构列表
     */
    @GetMapping("/list")
    public RestResponse list(DeptUser deptUser)
    {
//        startPage();

        List<DeptUser> list = deptUserService.selectDeptUserList(deptUser);
        return RestResponse.success(list);
    }
    

    /**
     * 获取部门人员组织架构详细信息
     */
    @GetMapping(value = "/{id}")
    public RestResponse getInfo(@PathVariable("id") Long id)
    {
        return RestResponse.success(deptUserService.selectDeptUserById(id));
    }

    /**
     * 新增部门人员组织架构
     */
    @PostMapping
    public RestResponse add(@RequestBody DeptUser deptUser)
    {
        return RestResponse.success(deptUserService.insertDeptUser(deptUser));
    }

    /**
     * 修改部门人员组织架构
     */
    @PutMapping
    public RestResponse edit(@RequestBody DeptUser deptUser)
    {
        return RestResponse.success(deptUserService.updateDeptUser(deptUser));
    }

    /**
     * 删除部门人员组织架构
     */
	@DeleteMapping("/{ids}")
    public RestResponse remove(@PathVariable Long[] ids)
    {
        return RestResponse.success(deptUserService.deleteDeptUserByIds(ids));
    }
}
